package name.luojun.DBhelper;
import java.util.HashMap;
import java.util.Map;
public class SqlType {
	public static Map<String, String> oracleSqlMap = new HashMap<String, String>();
	public static Map<String, String> MySqlMap = new HashMap<String, String>();
	public static Map<String, String> originType = new HashMap<String, String>();
	static {
		oracleSqlMap.put("String", "VARCHAR2");
		oracleSqlMap.put("int", "NUMBER");
		oracleSqlMap.put("long", "NUMBER");
		oracleSqlMap.put("short", "NUMBER");
		oracleSqlMap.put("byte", "NUMBER");
		oracleSqlMap.put("date", "DATE");
		MySqlMap.put("String", "VARCHAR");
		MySqlMap.put("int", "INT");
		MySqlMap.put("long", "BIGINT");
		MySqlMap.put("short", "INT");
		MySqlMap.put("byte", "INT");
		MySqlMap.put("date", "DATE");
		originType.put("VARCHAR2", "String");
		originType.put("VARCHAR", "String");
		originType.put("NUMBER", "int");
		originType.put("INT", "int");
		originType.put("BIGINT", "long");
		originType.put("DATE", "date");
	}
	public static String getSqlType(String localtype) {
		return oracleSqlMap.get(localtype);
	}
	public static String getLocalType(String sqltype) {
		return null;
	}
	public static int getDefaultLength(String sqltype) {
		if (sqltype.equalsIgnoreCase("NUMBER")) {
			return 15;
		} else if (sqltype.equalsIgnoreCase("VARCHAR2")) {
			return 255;
		} else {
			return 255;
		}
	}
	public static String getSqlType(String type, String dialect) {
		if (dialect.equalsIgnoreCase("Mysql")) {
			return MySqlMap.get(type);
		} else if (dialect.equalsIgnoreCase("oracle")) {
			return oracleSqlMap.get(type);
		} else {
			return oracleSqlMap.get(type);
		}
	}
	public static String getType(String type, String dialect) {
		return originType.get(type.toUpperCase());
	}
}
